package application

import (
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/service"

	"github.com/labstack/echo/v4"
)

type TokenApplication struct {
	TokenService *service.TokenService
}

func NewTokenApplication(u *service.TokenService) *TokenApplication {
	return &TokenApplication{
		TokenService: u,
	}
}

func (s *TokenApplication) CreateToken(e echo.Context, loginUser *model.LoginUser) (string, error) {
	return s.TokenService.CreateToken(e, loginUser)
}

func (s *TokenApplication) CacheToken(e echo.Context, uuid, token string) error {
	return s.TokenService.CacheToken(e, uuid, token)
}

func (s *TokenApplication) GetLoginUser(e echo.Context) (*model.LoginUser, error) {
	return s.TokenService.GetLoginUser(e)
}

func (s *TokenApplication) SetLoginUser(e echo.Context, loginUser *model.LoginUser) error {
	return s.TokenService.SetLoginUser(e, loginUser)
}

func (s *TokenApplication) DeleteLoginUser(e echo.Context) error {
	return s.TokenService.DeleteLoginUser(e)
}

func (s *TokenApplication) GetToken(e echo.Context, tokenKey, authPrefix string) (string, error) {
	return s.TokenService.GetToken(e, tokenKey, authPrefix)
}
